#!/usr/bin/python
# encoding: utf-8

import _actions

class LishActionError(Exception):
  "Raised when a call for delphi module was failed."
  pass

class Actions:
  def __init__ (self, mainform):
    self._mainform = mainform

  def setCommandMode (self):
    'change mode of main form into command mode.'
    res = _actions.setCommandMode(self._mainform)
    if res: raise LishActionError, res

  def setSelectMode (self):
    'change mode of main form into select mode.'
    res = _actions.setSelectMode(self._mainform)
    if res: raise LishActionError, res

  def close (self):
    'close main form.'
    res = _actions.close(self._mainform)
    if res: raise LishActionError, res

  def up (self, step):
    'move file list focus up by "step".'
    res = _actions.up(self._mainform, step)
    if res: raise LishActionError, res

  def down (self, step):
    'move file list focus down by "step".'
    res = _actions.down(self._mainform, step)
    if res: raise LishActionError, res

  def toggleSelection (self, index):
    'toggle file selection at "index".'
    res = _actions.toggleSelection(self._mainform, index)
    if res: raise LishActionError, res

  def selectAll (self):
    'select all files.'
    res = _actions.selectAll(self._mainform)
    if res: raise LishActionError, res

  def unselectAll (self):
    'unselect all files.'
    res = _actions.unselectAll(self._mainform)
    if res: raise LishActionError, res

  def contextMenu (self):
    'popup context menu for selected files'
    res = _actions.contextMenu(self._mainform)
    if res: raise LishActionError, res

  def dragDropContextMenu (self):
    'popup dragdrop context menu for dropped files'
    res = _actions.dragDropContextMenu(self._mainform)
    if res: raise LishActionError, res

  def dragStart (self):
    'start dragging'
    res = _actions.dragStart(self._mainform)
    if res: raise LishActionError, res

  def setDragDropEffect (self, effect):
    'set dragdrop effect'
    res = _actions.setDragDropEffect(self._mainform, effect)
    if res: raise LishActionError, res
